//************************************************
// File Name: LevelViewController.m
// Team: Team Epsilon
// Date Created: 2009/07/15
// Purpose: List the level completed. 
// Change History: 
//   * James, Date: 2009/07/15 Create File
//   * James, Date: 2009/07/16 Adding Lists
//   * James, Date: 2009/07/16 Create link to each level
//   * James, Date: 2009/07/16 Check Level complete function.
// Known Bugs:
//   1. The level complete function not working perfectly correct.
//   2. If level run once the check mark will not disappear(no reset).
//   3. Scroll does not work correctly.
//************************************************

#import "LevelViewController.h"
#import "Level0ViewController.h"
#import "SecondViewController.h"
#import "Level2ViewController.h"

//implementation for level view controller
@implementation LevelViewController

//check tutorial level completed
@synthesize checkCompleteTutorialLevel;

//check level1 completed
@synthesize checkCompleteLevel1;

//check level1 completed
@synthesize checkCompleteLevel2;

//action when click on the level button, go to tutorial level
-(IBAction)TutorialLevelPressed:(id)sender
{
	Level0ViewController *game0 = [[Level0ViewController alloc] initWithNibName:@"Level0View" bundle:nil];
	[UIView beginAnimations:nil context:NULL]; 
	[UIView setAnimationDuration:0.5]; 
	[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; 
	[self.view addSubview:game0.view]; 
	[UIView commitAnimations];
}

//action when click on the level butoon, go to level1
-(IBAction)Level1Pressed:(id)sender
{
	SecondViewController *game1 = [[SecondViewController alloc] initWithNibName:@"SecondView" bundle:nil];
	[UIView beginAnimations:nil context:NULL]; 
	[UIView setAnimationDuration:0.5]; 
	[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; 
	[self.view addSubview:game1.view]; 
	[UIView commitAnimations];
}

//action when click on the level butoon, go to level2
-(IBAction)Level2Pressed:(id)sender
{
	Level2ViewController *game2 = [[Level2ViewController alloc]initWithNibName:@"Level2View" bundle:nil];
	[UIView beginAnimations:nil context:NULL]; 
	[UIView setAnimationDuration:0.5]; 
	[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; 
	[self.view addSubview:game2.view]; 
	[UIView commitAnimations];
}

//action when click on the level butoon, go to level3
-(IBAction)Level3Pressed:(id)sender
{
	SecondViewController *game3 = [[SecondViewController alloc]initWithNibName:@"ThirdView" bundle:nil];
	[UIView beginAnimations:nil context:NULL]; 
	[UIView setAnimationDuration:0.5]; 
	[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; 
	[self.view addSubview:game3.view]; 
	[UIView commitAnimations];
}

//action when click on the level butoon, go to level4
-(IBAction)Level4Pressed:(id)sender
{
	SecondViewController *game4 = [ [SecondViewController alloc]initWithNibName:@"ThirdView" bundle:nil];
	[UIView beginAnimations:nil context:NULL]; 
	[UIView setAnimationDuration:0.5]; 
	[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; 
	[self.view addSubview:game4.view]; 
	[UIView commitAnimations];
}

//action when click on the level butoon, go to level5
-(IBAction)Level5Pressed:(id)sender
{
	SecondViewController *game5 = [ [SecondViewController alloc]initWithNibName:@"ThirdView" bundle:nil];
	[UIView beginAnimations:nil context:NULL]; 
	[UIView setAnimationDuration:0.5]; 
	[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; 
	[self.view addSubview:game5.view]; 
	[UIView commitAnimations];
}

//check if level complete function.
-(void)checkLevelCompleted
{
	if(checkCompleteTutorialLevel == 1)
	{
		checked.alpha = 1.00;
	}
	else if(checkCompleteLevel1 == 1)
	{
		checked.alpha = 1.00;
	}
	else if (checkCompleteLevel2 == 1)
	{
		checked.alpha = 1.00;
	}
	else
	{
		checked.alpha = 0.0;
	}
}
		

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

//memory warning 
- (void)didReceiveMemoryWarning 
{
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

//unload function
- (void)viewDidUnload 
{
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}

//memory deallocate function
- (void)dealloc 
{
    [super dealloc];
}


@end
